package com.hb.hb_casefile;



import java.sql.Connection;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.core.*;

import com.hb.hb_member.*;
import com.wonders.ips.common.*;

/**
 * @author zhubin
 *
 */
public class HbCasefileAction extends DispatchAction{ 

	public ActionForward save(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response){
		
	HbCasefileDAO dao=new HbCasefileDAO();
	HbCasefile hbcasefile=new HbCasefile();
	
	int caseid=0;
	if(request.getParameter("caseid")!=null && !request.getParameter("caseid").equals("") && !request.getParameter("caseid").equals("null")){
		caseid = Integer.parseInt(request.getParameter("caseid"));
	}
	String filename=request.getParameter("filename");
	String filepath=request.getParameter("filepath");

	dao.save(hbcasefile);

	request.setAttribute("HbCasefileAdd",hbcasefile);
	if(dao!=null)
		return mapping.findForward("addsuccess");
	else
		return mapping.findForward("savefail");	
	
}

public ActionForward mod(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response){
	

	int id=0;
	if(request.getParameter("id")!=null){
		id = Integer.parseInt(request.getParameter("id"));
	}
	HbCasefileDAO dao=new HbCasefileDAO();
	HbCasefile hbcasefile=new HbCasefile();
	
	hbcasefile=dao.findById(id);
	
	String filename=request.getParameter("filename");
	String filepath=request.getParameter("filepath");
	
	if(filename!=null && !("").equals(filename)){
	hbcasefile.setFilename(filename);
	}
	if(filepath!=null && !("").equals(filepath)){
		hbcasefile.setFilepath(filepath);
	}

	dao.attachDirty(hbcasefile);
    request.getSession().setAttribute("HbCasefilebo", hbcasefile);
    return mapping.findForward("modsuccess");

}

}
